package com.maserb.monitor.runner;

import com.maserb.monitor.dataCenter.communication.DataCenterServer;
import com.maserb.monitor.database.JdbcTemplateFactory;
import com.maserb.monitor.remote.AFSTServer;
import com.maserb.monitor.repository.cache.ConfigurationTreeCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;

public class MonitorAppRunner implements ApplicationRunner {

    @Autowired
    ConfigurationTreeCache configurationTreeCache;
    @Autowired
    JdbcTemplateFactory jdbcTemplateFactory;


    @Value("${monitor.dataCenter.port}")
    int dataCenterPort;

    @Autowired
    DataCenterServer dataCenterServer;

    @Autowired
    AFSTServer afstServer;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        try {
//            jdbcTemplateFactory.init();
//            treeService.init(Long.MAX_VALUE);
//
//            //启动服务器接收数据
//            dataCenterServer.bind(dataCenterPort);

            afstServer.bind(dataCenterPort);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
